package com.tz.common.util;

import android.content.Context;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

import java.util.HashMap;
import java.util.Map;

/**
 * Network data util
 * Created by Chris on 16/7/19.
 */
public class VolleyDataUtils {

    private static final int TIMEOUT_MILLISECONDS = 10 * 60 * 1000;

    // volley queue
    private static RequestQueue mVolleyQueue;

    //Http headers
    public static Map<String, String> mHeaders;

    public static void init(Context context) {
        mVolleyQueue = Volley.newRequestQueue(context);
        mHeaders = new HashMap<>();
    }

    public static void addRequest(Request<?> request) {
        request.setRetryPolicy(new DefaultRetryPolicy(TIMEOUT_MILLISECONDS, 1, 1.0f));
        mVolleyQueue.add(request);
    }

}
